package com.chen.aspect;

import com.chen.annotation.MyAnnotation;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author cgj
 * @date 3/30/25 7:16 PM
 */
@Aspect
@Component
public class MyAspect {
    @Around(value = "@annotation(myAnnotation)")
    public Object doConcurrentOperation(ProceedingJoinPoint pjp, MyAnnotation myAnnotation)  {
        Object proceed=null;
        try {
            System.out.println(myAnnotation.title());
            System.out.println("方法执行前");
            proceed = pjp.proceed(); //执行被增强的方法
            System.out.println("方法执行后");
            return proceed;
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return  proceed;
    }
}
